/**
 * Auto gen via dbpojo-gen.
 */
package com.us.usws.dao;

import java.util.List;

import net.iwsh.core.db.DBExecutor;
import net.iwsh.core.db.ext.DialectSyntaxParser;
import net.iwsh.core.db.ext.SQLWithParams;

import com.us.usws.model.domain.channel.ChannelFilter;
import com.us.usws.model.flat.channel.DOChannelFilter;

/**
 * DAO class
 * @author robot
 */
public class ChannelFilterDAO {

	/**
	 * Query SQLs
	 */
	private static final String SQL_GET_TOTAL_COUNT = "select count(*) from hv_channel_filter";
	private static final String SQL_GET_ALL_CHANNELFILTERS = "select * from hv_channel_filter";

	/**
	 * CUR SQLs
	 */
	private static final String SQL_INSERT_CHANNELFILTER = "insert into hv_channel_filter(channel_uid,filter_name,filter_value,seq_num) values (?,?,?,?)";

	/**
	 * DBExeutor
	 */
	private DBExecutor dbe = new DBExecutor();

	/**
	 * Get Count.
	 */
	public int getTotalCount() {
		return dbe.getCount(SQL_GET_TOTAL_COUNT);
	}

	/**
	 * Get all list.
	 */
	public List<ChannelFilter> getAllChannelFilters() {
		return dbe.list(SQL_GET_ALL_CHANNELFILTERS, ChannelFilter.class);
	}

	/**
	 * Get all list by pagination.
	 */
	public List<ChannelFilter> getChannelFilters(int start, int end) {
		SQLWithParams swp = DialectSyntaxParser.getParser().getPaginationSQLWithParams(SQL_GET_ALL_CHANNELFILTERS, null, start, end);
		return dbe.list(swp.getSql(), ChannelFilter.class, swp.getParams());
	}

	/**
	 * Insert one row.
	 */
	public String insertChannelFilter(DOChannelFilter channelFilter) {
		dbe.execute(SQL_INSERT_CHANNELFILTER, channelFilter.getChannelUid(), channelFilter.getFilterName(), channelFilter.getFilterValue(),
				channelFilter.getSeqNum());
		return channelFilter.getChannelUid();
	}

}